package com.woniuxy.intellihome.controller;


import com.woniuxy.intellihome.entity.Review;
import com.woniuxy.intellihome.entity.Sku;
import com.woniuxy.intellihome.entity.User;
import com.woniuxy.intellihome.service.ReviewService;
import com.woniuxy.intellihome.service.SkuService;
import com.woniuxy.intellihome.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2021-08-11
 */
@Controller
@RequestMapping("admin/review")
public class ReviewController {
    @Autowired
    private ReviewService reviewService;
    @Autowired
    private UserService userService;
    @Autowired
    private SkuService skuService;

    @GetMapping("list")
    public void list(Model model) {
        List<Review> reviews = reviewService.list();
        List<User> users = new ArrayList<>();
        List<Sku>skus=new ArrayList<>();
        for (Review review : reviews) {
            users.add(userService.getById(review.getUserId()));
//            skus.add(skuService.getById(review.getSkuId()));

        }
//    return "admin/review_list";
//        return "ok";
    }
}

